/*
 * interrupts.c
 *
 *  Created on: Apr 15, 2013
 *      Author: Kurt Hardin
 */

#include <msp430.h>

extern char i2cRxHandler(void);
extern char i2cTxHandler(void);
extern char i2cNackHandler(void);

extern char uartRxHandler(void);

#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR_HOOK(void) {
	char lpmToExit = 0;												// Default, no change
	if (IFG2 & UCB0TXIFG) {
		lpmToExit = i2cTxHandler();
	}
	else if (IFG2 & UCB0RXIFG) {
		lpmToExit = i2cRxHandler();
	}
	__bic_SR_register_on_exit(lpmToExit);
}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR_HOOK(void)
{
	char lpmToExit = 0;													// Default, no change
	if (IFG2 & UCA0RXIFG) {
		lpmToExit = uartRxHandler();
	}
	else if (IFG2 & UCB0RXIFG) {
		if (UCB0STAT & UCNACKIFG) {
			lpmToExit = i2cNackHandler();
		}
	}
	__bic_SR_register_on_exit(lpmToExit);
}
